package test1.Demo2;

/**
 * ClassName Test
 * Description TODO
 * Author Yanyan
 * Date 2025/11/8 19:48
 * Version 1.0
 */
public class Test {

    public static void main(String[] args) {

        Student stundent1 = new Student();
        System.out.println("===============");
        Student student2 = new Student();
        System.out.println(Student.classRoom);
    }

    public static void main7(String[] args) {
        //普通代码块
        {
            int a = 10;
            System.out.println(a);
        }
        //代码块内的变量生命周期只在代码块执行中
        //所以报错了
        //System.out.println(a);
    }

    public static void main6(String[] args) {
        Student student1 = new Student("张三",10);
        System.out.println(student1.getName());
    }

    public int add(int a,int b) {
        return a + b;
    }

    public static void main5 (String[] args) {
        Student stundent1 =new Student("张三",12);
        stundent1.testFunc();
        System.out.println(stundent1.getName());

        Student.testStatic();

        Test test = new Test();
        test.add(1,2);

    }

    public static void main3(String[] args) {
        Student.classRoom = "2234";
    }

    public static void main2(String[] args) {
        Student student1 = new Student("张三",10);
        Student.classRoom = "B1123";

        Student student2 = new Student("李四",14);
        System.out.println(student2.classRoom);
        System.out.println(student1.classRoom);
        //可以用对象访问静态成员，但最好用类名
    }


    //类的调用者
    public static void main1(String[] args) {
        Student student = new Student("老王",40);
        //private使下面的方法无法再修改
        //student.name = "你好";
        //System.out.println(student.name);

        student.setName("赵霖");
        System.out.println(student.getName());
    }
}
